/************************
Replication File for Analysis Included in Kinane, CM. "Control Without Confirmation: The Politics of Vacancies in Presidential Appointments." American Political Science Review.
**************************/

*set directory location of dta files 
*cd " "

ssc install mplotoffset


use "Kinane_APSR_annualperc_vacancies.dta", clear

/**** Figure 1: Percentage executive department PAS positions graph ****/

twoway (line pct_empty Year, lc("211 211 211") lwidth(thick) ) (line pct_acting Year, lc("168 168 168") lwidth(thick) ) ///
	(line pct_vacancy Year, lc("123 123 123") lwidth(thick)), ///
	xlabel(1977(2)2015, angle(90) glc(gs15) labc(gs6) labsize(medsmall)) xsize(12) ysize(8)  ///
	scheme(538w) xtitle("")  ylabel(, labc(gs5) labsize(medsmall)) ///
	legend(pos(6) label(1 "Empty") label(2 "Interim") label(3 "Vacancy") color(gs6) rows(1) size(medsmall)) ///
	ytitle("Percent of PAS Positions", size(medsmall) m(r=3) color(gs4) ) ///
	xline(2009 2001 1993 1989 1981 1977, lp(shortdash) lc("120 120 120")) 


/**** Remaining Analysis ****/
	
use "Kinane_APSR_Control_replication.dta", clear

global regcov "i.pres_position_value##i.cong_position_value i.copartisan_control  i.estab_admin ib1.procedural_regime ib3.department  i.admin "

global probcov "i.pres_position_value i.cong_position_value i.copartisan_control  i.estab_admin i.procedural_regime"

global regcovFVRA "i.pres_position_value##i.cong_position_value i.copartisan_control  i.estab_admin ib3.department  i.admin"

global regcovR1 "i.pres_position_value##i.cong_position_value i.copartisan_control  i.estab_term ib1.procedural_regime ib3.department  i.admin_term"

global regcovR2 "i.pres_priorities i.position_capacity	i.cong_priorities  	ib0.pres_position_value#ib0.cong_position_value i.copartisan_control  i.estab_admin ib1.procedural_regime ib3.department  i.admin"


/*** Table 1 - Distributions of Permanent Appointees and Vacancies***/

tab pres_position_value Permanent, row col chi2

tab pres_position_value Vacancy_cat , row col chi2

tab  pres_position_value Vacancy_cat if Vacancy_cat!=3, row col chi2


/*** Table B2 - Distribution of Permanent Appointees and Vacancies, non-Defense***/


tab pres_position_value Vacancy_cat if department!=3 , row col chi2

tab  pres_position_value Vacancy_cat if Vacancy_cat!=3 & department!=3, row col chi2



/*** Table B3 - MNP results (main model)  ***/


mprobit Vacancy_cat $regcov, baseoutcome(3)  vce(robust)
	 
	

/*** Table 2 - Predicted Probabilities of Position Status Outcomes ***/

quietly mprobit Vacancy_cat $regcov   , baseoutcome(3)  vce(robust)
		   
margins i.pres_position_value $probcov, predict(outcome(3)) atmeans post
	  
estimates store predprob_perm
		

quietly mprobit Vacancy_cat $regcov, baseoutcome(3)  vce(robust)
		
margins $probcov, predict(outcome(2)) atmeans post
	  
estimates store predprob_interim
		
	
quietly mprobit Vacancy_cat $regcov   , baseoutcome(3)  vce(robust)
			
margins $probcov, predict(outcome(1)) atmeans post
	  
estimates store predprob_empty

estimates table predprob_perm predprob_interim predprob_empty, b(%10.4f) se  varwidth(25) 	  
	

/*** Narrative pairwise compare tests ***/
		

quietly mprobit Vacancy_cat $regcov   , baseoutcome(3)  vce(robust)
		   		
					
*Position Value
		
margins i.pres_position_value, atmeans predict(outcome(1))    pwcompare(pveffects) 
		
margins i.pres_position_value, atmeans predict(outcome(2))    pwcompare(pveffects) 

margins i.pres_position_value, atmeans predict(outcome(1))  predict(outcome(2))   pwcompare(pveffects) 
				
*Co-partisan control				
		
margins i.copartisan_control, predict(outcome(3)) atmeans pwcompare(pveffects)
	
*Establish Admin
		
margins i.estab_admin, predict(outcome(2)) atmeans pwcompare(pveffects)
		
margins i.estab_admin, predict(outcome(1)) predict(outcome(2)) atmeans pwcompare(pveffects)

*Vacancy Regime

margins i.procedural_regime, predict(outcome(1)) atmeans pwcompare(pveffects)
		
margins i.procedural_regime, predict(outcome(2)) atmeans pwcompare(pveffects)

margins i.procedural_regime, atmeans predict(outcome(1)) predict(outcome(2)) 

margins i.procedural_regime, atmeans predict(outcome(1)) predict(outcome(2)) pwcompare(pveffects)
		
margins i.pres_position_value, atmeans predict(outcome(1)) predict(outcome(2))  over(procedural_regime) pwcompare(pveffects)



/*** Figure 3 - Adjusted Predictions of Probability Empty and Interim, given Pres position value ***/

quietly mprobit Vacancy_cat $regcov   , baseoutcome(3)  vce(robust)

margins i.pres_position_value, atmeans  predict(outcome(1)) predict(outcome(2)) saving(m_prespv, replace) 


mplotoffset, recast(scatter)  scheme(plotplain) recastci(rcap)  offset(.15) plotopts(msym(o)) ///
	plot1opts(mc("153 153 153") msize(medlarge)) ci1opts(lc("153 153 153") lw(medthick)) ///
		plot2opts(mc("85 85 85") msize(medlarge)) ci2opts(lc("85 85 85") lw(medthick)) ///
	xlabel( 0 ""  0.05 "0.05" 0.1 "0.1" .12 " ", ///
	labsize(medlarge)) xline(0, lc(gs8) lpattern(dash))  ///
	ylabel(-0.5 " " 0 "Low Value" 1 "High Value (contraction)" 2 "High Value (expansion)" 2.5 " " , labsize(medium) noticks) ///
	ytitle("President Position Value", m(r=5) size(medium)) xtitle("Predicted Probability", size(medium)) title("") horizontal ///
	legend(title("Position Status") order(1 2) label(1 "Empty Position") ///
	label(2 "Interim Appointee") pos(6) r(1) colgap(10) )


	

/*** Figure 4 - Adjusted Predictions of Probability Empty and Interim, given Pres position value and vacancy procedural regime ***/


margins i.pres_position_value, atmeans predict(outcome(1)) predict(outcome(2))  over(procedural_regime) 

mplotoffset, xsize(7) graphregion(m(vsmall)) plotregion(m(r=2)) recast(scatter)  scheme(plotplain) recastci(rcap)  offset(.1) plotopts(msym(o)) ///
		plot1opts(mc(gs9) msize(small) msymbol(D)) ci1opts(lc(gs9) lw(medthick) lp(dash) ) ///
		plot2opts(mc(gs6) msize(small) msymbol(D)) ci2opts(lc(gs6) lw(medthick) lp(dash)) ///
		plot3opts(mc(gs9) msize(small) msymbol(O)) ci3opts(lc(gs9) lw(medthick) lp(shortdash)) ///
		plot4opts(mc(gs6) msize(small) msymbol(O)) ci4opts(lc(gs6) lw(medthick) lp(shortdash)) ///
		plot5opts(mc(gs9) msize(small) msymbol(T)) ci5opts(lc(gs9) lw(medthick)) ///
		plot6opts(mc(gs6) msize(small) msymbol(T)) ci6opts(lc(gs6) lw(medthick)) ///
	ylabel(-0.005 " " 0 "0" 0.02 ".02" 0.04 ".04" 0.06 ".06" 0.08 ".08" .1 ".1" .12 ".12" .14 ".14" .15 " ", ///
	labsize(medsmall)) yline(0, lc("204 204 204") lpattern(dash))  ///
	xlabel(-0.5 " " 0 "Low Value" 1 "High Value" 2 "High Value" 2.75 " " , labsize(small) noticks ) ///
	xtitle("President Position Value", m(t=5) size(medsmall)) ytitle("Predicted Probability", size(medsmall) m(r=5)) title("")  ///
		legend(region(m(l=5)) title("Procedural Regime by Position Status", m(b=2) size(medsmall))  all order(- "Empty Position:"  1 3 5 - " " - "Interim Appointee:" 2 4 6) symxsize(10) label(1 "Vacancy Act (1977-1987)") ///
	label(2 "Vacancy Act (1977-1987)") label(3 "Transition Effectiveness Act (1988-1997)") label(4 "Transition Effectiveness Act (1988-1997)") ///
	label(5 "FVRA (1998-2016)") label(6 "FVRA (1998-2016)") pos(3) c(1) colgap(4) size(small)    )
	
	

/*** Table B4 - MNP results pre and post FVRA ***/

/** Pre FVRA **/

mprobit Vacancy_cat $regcovFVRA  if Year<1998  , baseoutcome(3)  vce(robust)
	  
estimates store model2pre


margins i.pres_position_value, predict(outcome(1)) predict(outcome(2)) predict(outcome(3)) atmeans pwcompare(pveffects)

margins i.pres_position_value, predict(outcome(1)) predict(outcome(2)) predict(outcome(3)) atmeans post

estimates store m_pre

/** Post FVRA **/


mprobit Vacancy_cat $regcovFVRA  if Year>=1998  , baseoutcome(3)  vce(robust)
	  
estimates store model2post

margins i.pres_position_value, predict(outcome(1)) predict(outcome(2)) predict(outcome(3)) atmeans pwcompare(pveffects)

margins i.pres_position_value, predict(outcome(1)) predict(outcome(2)) predict(outcome(3)) atmeans post

estimates store m_post


estimates table model2pre model2post, varwidth(25) b(%10.4f) se

/*** Table B5 - Predicted Probabilities of Position Status Outcome, Pre and Post FVRA ***/

estimates table m_pre m_post , varwidth(25) b(%10.4f) se 
		


/*** Figure 5 - Adjusted Predictions of the Probability of Empty and Interim, given Pres position value, Pre and Post FVRA ***/


quietly mprobit Vacancy_cat $regcovFVRA   if Year<1998  , baseoutcome(3)  vce(robust)


margins i.pres_position_value, atmeans predict(outcome(1)) predict(outcome(2)) 
	
mplotoffset, recast(scatter)  scheme(plotplain) recastci(rcap)  offset(.15) plotopts(msym(o)) ///
	plot1opts(mc(gs9) msize(medlarge)) ci1opts(lc(gs9) lw(medthick)) ///
		plot2opts(mc(gs6) msize(medlarge)) ci2opts(lc(gs6) lw(medthick)) ///
	xlabel(0 "" 0.05 "0.05" 0.1 "0.1" 0.15 "0.15" 0.17 " ", ///
	labsize(medlarge)) xline(0, lc(gs3) lpattern(dash))  ///
	ylabel(-0.5 " " 0 "Low Value" 1 "High Value (contraction)" 2 "High Value (expansion)" 2.5 " " , labsize(medium) noticks) ///
	ytitle("President Position Value", m(r=5) size(medium)) xtitle("Predicted Probability", size(medium)) title("Pre-FVRA (1977-1997)") horizontal ///
	legend(title("Position Status") order(1 2) label(1 "Empty Position") ///
	label(2 "Interim Appointee") pos(6) r(1) colgap(10) ) 
		
	

mplotoffset, recast(scatter)  scheme(plotplain) recastci(rcap)  offset(.15) plotopts(msym(o)) ///
	plot1opts(mc(gs9) msize(medlarge)) ci1opts(lc(gs9) lw(medthick)) ///
		plot2opts(mc(gs6) msize(medlarge)) ci2opts(lc(gs6) lw(medthick)) ///
	xlabel(0 "" 0.05 "0.05" 0.1 "0.1" 0.15 "0.15" 0.17 " ", ///
	labsize(medlarge)) xline(0, lc(gs3) lpattern(dash))  ///
	ylabel(-0.5 " " 0 "Low Value" 1 "High Value (contraction)" 2 "High Value (expansion)" 2.5 " " , labsize(medium) noticks) ///
	ytitle("President Position Value", m(r=5) size(medium)) xtitle("Predicted Probability", size(medium)) title("Pre-FVRA (1977-1997)") horizontal ///
	legend(off)
	
	

quietly mprobit Vacancy_cat $regcovFVRA if Year>=1998  , baseoutcome(3)  vce(robust)

margins i.pres_position_value, atmeans predict(outcome(1)) predict(outcome(2)) vce(unconditional)
	
mplotoffset, recast(scatter)  scheme(plotplain) recastci(rcap)  offset(.15) plotopts(msym(o)) ///
	plot1opts(mc(gs9) m(d) msize(medlarge)) ci1opts(lc(gs9) lw(medthick)) ///
		plot2opts(mc(gs6) m(d) msize(medlarge)) ci2opts(lc(gs6) lw(medthick)) ///
	xlabel(0 "" 0.05 "0.05" 0.1 "0.1" 0.15 "0.15" 0.17 " ", ///
	labsize(medlarge)) xline(0, lc(gs3) lpattern(dash))  ///
	ylabel(-0.5 " " 0 "Low Value" 1 "High Value (contraction)" 2 "High Value (expansion)" 2.5 " " , labsize(medium) noticks) ///
	ytitle("President Position Value", m(r=5) size(medium)) xtitle("Predicted Probability", size(medium)) title("Post-FVRA(1998-2016)") horizontal ///
	legend(title("Position Status") order(1 2) label(1 "Empty Position") ///
	label(2 "Interim Appointee") pos(6) r(1) colgap(10) )
	


mplotoffset, recast(scatter)  scheme(plotplain) recastci(rcap)  offset(.15) plotopts(msym(o)) ///
	plot1opts(mc(gs9) m(d) msize(medlarge)) ci1opts(lc(gs9) lw(medthick)) ///
		plot2opts(mc(gs6) m(d) msize(medlarge)) ci2opts(lc(gs6) lw(medthick)) ///
	xlabel(0 "" 0.05 "0.05" 0.1 "0.1" 0.15 "0.15" 0.17 " ", ///
	labsize(medlarge)) xline(0, lc(gs3) lpattern(dash))  ///
	ylabel(none) ///
	ytitle(" ") xtitle(" ") title("Post-FVRA (1998-2016)") horizontal ///
	legend(off)



/****
Appendix Robustness
*****/

/*** Table B6 and B7 - Alternative Specifications of Likelihood Models ***/

mprobit Vacancy_cat $regcov   , baseoutcome(3)  vce(robust)

estimates store append_model1

fitstat

mprobit Vacancy_cat $regcovR1  , baseoutcome(3) vce(robust) 
		
estimates store append_model2

fitstat

mprobit Vacancy_cat  $regcovR2 , baseoutcome(3) vce(robust) 
			
estimates store append_model3

fitstat

estimates table append_model1 append_model2 append_model3 , b(%10.4f) se  varwidth(25) stats(r2 N chi2 aic bic rank ll Wald)

